﻿using System;
using System.Globalization;

namespace Budget.Silver.Core.Extensions
{
    public static class StringExtensions
    {
        public static Boolean TryParseToDecimal(this String str, out Decimal value)
        {
            return Decimal.TryParse(str, out value) ||
                   Decimal.TryParse(str, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out value);
        }

        public static Decimal ParseToDecimal(this String str)
        {
            Decimal d = 0;

            str.TryParseToDecimal(out d);

            return d;
        }
    }
}